#ifndef MONITOR_H_
#define MONITOR_H_
#include <sys/time.h>
#ifdef ENABLE_MONITOR
#define DB_INIT \
	struct timeval db_start, db_end;\
	long db_mtime, db_seconds, db_useconds;
#define DB_START \
	gettimeofday(&db_start, NULL);
#define DB_STOP \
	gettimeofday(&db_end, NULL); \
	db_seconds  = db_end.tv_sec  - db_start.tv_sec; \
	db_useconds = db_end.tv_usec - db_start.tv_usec; \
	db_mtime = ((db_seconds) * 1000 + db_useconds/1000.0) + 0.5; \
	monitor::db += db_mtime;
#define DB_REPORT \
	printf("total db time = %ld milliseconds\n", monitor::db);


#define TREE_INIT \
	struct timeval tree_start, tree_end;\
	long tree_mtime, tree_seconds, tree_useconds;
#define TREE_START \
	gettimeofday(&tree_start, NULL);
#define TREE_STOP \
	gettimeofday(&tree_end, NULL); \
	tree_seconds  = tree_end.tv_sec  - tree_start.tv_sec; \
	tree_useconds = tree_end.tv_usec - tree_start.tv_usec; \
	tree_mtime = ((tree_seconds) * 1000 + tree_useconds/1000.0) + 0.5; \
	monitor::tree += tree_mtime;
#define TREE_REPORT \
	printf("total tree time = %ld milliseconds\n", monitor::tree);
#else
#define DB_INIT
#define DB_START
#define DB_STOP
#define DB_REPORT
#define TREE_INIT
#define TREE_START
#define TREE_STOP
#define TREE_REPORT

#endif
namespace monitor {
extern long db;
extern long tree;
};
#endif
